﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DICOMViewer.Utility
{
    public class Logger
    {
        static readonly string LogDirFilePath = System.Windows.Forms.Application.StartupPath +  "\\log\\";
        static FileStream fstream;

        public static void Log(string Msg)
        {
            string todayFilename = LogDirFilePath +  DateTime.Now.ToString("yyyy-MM-dd") + ".log";
            if (!Directory.Exists(LogDirFilePath))
            {
                Directory.CreateDirectory(LogDirFilePath);
            }
            if (!File.Exists(todayFilename))
            {
                fstream = File.Create(todayFilename);
            }
            else
            {
                fstream = File.OpenWrite(todayFilename);
            }
            StreamWriter sw = new StreamWriter(fstream);
            sw.WriteLine(Msg);
            sw.Close();
            sw.Dispose();
            fstream.Close();
            fstream.Dispose();
            fstream = null;

        }
    }
}
